/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package FuenteDeDatos;
import java.sql.SQLException;
import java.util.Observable;
import java.util.Observer;

/**
 *
 * @author Luis
 */
public class DataCheckBox extends javax.swing.JCheckBox implements Observer{

    private String campo;
    private DataSource data=null;

    //private datasource data2;



     public void conectar(){

         this.getData().addObserver(this);
        //getData().addObserver(this);

     }


    public void update(Observable o, Object o1) {

        this.setText("");


        try {

            if(this.data.rs.getString(this.getCampo()).equals("1")){
                this.setSelected(true);

            }else{

                this.setSelected(true);
            }

        } catch (SQLException ex) {
            this.setText("");
        }
    }


    public String getCampo() {
        return campo;
    }

    /**
     * @param campo the campo to set
     */
    public void setCampo(String campo) {
        this.campo = campo;
    }


    public DataSource getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(DataSource data) {
        this.data = data;
        if(data!=null){
            this.conectar();

        }
    }

    /**
     * @return the bande
     */




}
